//
//  ThingsCollectionViewCell.m
//  EducationAdminClient
//
//  Created by kwsdzjx on 16/9/8.
//  Copyright © 2016年 周佳兴. All rights reserved.
//

#import "ThingsCollectionViewCell.h"
#import "Masonry.h"
#import "UIColor+CL.h"
//#import "UIStyle.h"
#import "EducationAdminClient_URL.h"
@implementation ThingsCollectionViewCell
-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatUI];
        self.contentView.backgroundColor =[UIColor colorWithRed:231/255.0 green:231/255.0 blue:231/255.0 alpha:1];
    }
    return self;
}

-(void)creatUI{
    
    _v= [[UIView alloc]init];
    [self.contentView addSubview:_v];
    _v.backgroundColor =[UIColor whiteColor];
    
    
//#ifdef Main
    
    //#ifdef Main
    if([getUIStyle() isEqualToString:STYLE0]){
        [_v mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left);
            make.right.equalTo(self.contentView.mas_right);
            make.top.equalTo(self.contentView.mas_top);
            make.bottom.equalTo(self.contentView.mas_bottom);
        }];
    }else{
//#elif Student
        [_v mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left);
            make.right.equalTo(self.contentView.mas_right);
            make.top.equalTo(self.contentView.mas_top);
            make.bottom.equalTo(self.contentView.mas_bottom);
        }];
        
        _lineTop = [[UIView alloc] init];
        _lineButtom = [[UIView alloc] init];
        
        _lineTop.backgroundColor = [UIColor colorWithHex:0xdcdcdc];
        _lineButtom.backgroundColor = [UIColor colorWithHex:0xdcdcdc];
        
        [_v addSubview:_lineTop];
        [_v addSubview:_lineButtom];
        
        
        _lineRight = [[UIView alloc] init];
        
        [_v addSubview:_lineRight];
        _lineRight.backgroundColor = [UIColor colorWithHex:0xdcdcdc];
        
        [_lineRight mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(1));
            make.top.equalTo(_v.mas_top);
            make.bottom.equalTo(_v.mas_bottom);
            make.right.equalTo(_v.mas_right);
        }];

        [_lineTop mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@(1));
            make.top.equalTo(_v.mas_top);
            make.left.equalTo(_v.mas_left);
            make.right.equalTo(_v.mas_right);
        }];
        [_lineButtom mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.equalTo(@(1));
            make.bottom.equalTo(_v.mas_bottom);
            make.left.equalTo(_v.mas_left);
            make.right.equalTo(_v.mas_right);
        }];
    }
//#endif
    
    
    _titleImg =[[UIImageView alloc]init];
    [_v addSubview:_titleImg];
    [_titleImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_v.mas_centerX);
        make.top.equalTo(_v.mas_top).offset(15);// 12
        if([getUIStyle() isEqualToString:STYLE0]){
            make.width.equalTo(@(30));
            make.height.equalTo(@(30));
        }
    }];
    
    _titleImg2 =[[UIImageView alloc]init];
    
    
    [_v addSubview:_titleImg2];
    [_titleImg2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_v.mas_centerX);
        make.centerY.equalTo(_v.mas_centerY);
        make.width.equalTo(@(50));
        make.height.equalTo(@(10));
    }];
    _titleImg2.image = [UIImage imageNamed:@"123"];
    _titleImg2.hidden = YES;
    _titleLa = [[UILabel alloc]init];
//    [_titleLa sizeToFit]; // 距顶 ----  高度 不够
    [_v addSubview:_titleLa];
    _titleLa.numberOfLines = 0;
    
//#ifdef Main
    
    //#ifdef Main
    if([getUIStyle() isEqualToString:STYLE0]){
        [_titleLa mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.centerX.equalTo(_titleImg.mas_centerX);
            make.top.equalTo(_titleImg.mas_bottom).offset(10/2);
            make.bottom.equalTo(_v.mas_bottom).offset(-5);
            make.left.equalTo(_v.mas_left);
            make.right.equalTo(_v.mas_right);
        }];
        
    }else{
//#elif Student
        [_titleLa mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_titleImg.mas_centerX);
            make.top.equalTo(_titleImg.mas_bottom).offset(44/2);
            make.left.equalTo(_v.mas_left);
            
            make.right.equalTo(_v.mas_right);
        }];
    }
//#elif Teacher
//    //    rootview
//    NSLog(@"老师端程序");
//#else
//    
//    NSLog(@"都不是");
//#endif
    
   
    
    
    _titleLa.lineBreakMode = NSLineBreakByTruncatingTail;
    _titleLa.textAlignment = NSTextAlignmentCenter;
    _titleLa.font = [UIFont systemFontOfSize:30/2];
    _titleLa.text = @"";
    
    _titleLa.textColor = [UIColor colorWithHex:0x333333];
}

-(void)changeLine:(NSIndexPath *)indexPath{
    NSLog(@"%zd",indexPath.row);
    
    if (indexPath.row<3) {
        _lineTop.hidden = NO;
    }else{
        _lineTop.hidden = YES;
    }
    
}


-(void)changeRect:(BOOL)isChange{
    if(isChange){
        _titleImg2.hidden = NO;
        _titleImg.hidden = YES;
        _titleLa.hidden = YES;
    }else{
        _titleImg2.hidden = YES;
        _titleImg.hidden = NO;
        _titleLa.hidden = NO;
    }
}

@end
